//
//  WQCViewController.swift
//  3-微博
//
//  Created by DDDD on 16/2/24.
//  Copyright © 2016年 gongsimingzi. All rights reserved.
//

import UIKit

class WQCViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
       
        let tabbar = WQCTabBar()
        //
        setValue(tabbar, forKey: "tabBar")
        
        tabbar.composeButton.addTarget(self, action: "showPublish", forControlEvents: UIControlEvents.TouchUpInside)
        
        addChildViewController()
               // Do any additional setup after loading the view.
    }
        //按钮点击方法
    func showPublish(){
        print("点了我")
    }

    
    // 抽取的方法
    func addChildViewController() {
        addChildViewController(WQCHomeViewController(), title: "首页", image: "tabbar_home")
        addChildViewController(WQCMessageViewController(), title: "消息", image: "tabbar_message_center")
        addChildViewController(WQCFindViewController(), title: "发现", image: "tabbar_discover")
        addChildViewController(WQCSettingViewController(), title: "设置", image: "tabbar_profile")

    }
    //重载设置方法
    func addChildViewController(childController: UIViewController,title :String, image: String) {
        
        childController.title = title
        
        childController.tabBarItem.image = UIImage(named: image)
        
        childController.tabBarItem.selectedImage = UIImage(named: "\(image)_highlighted")
        //tabbar  不用系统默认渲染  自己设置颜色
//        UITabBar.appearance().tintColor = UIColor.orangeColor()
        
        addChildViewController(UINavigationController(rootViewController: childController))
    
    }
    
}
